<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>修改班级</title>
<link href="../css/bootstrap-cerulean.css" rel="stylesheet">
<link href="../css/charisma-app.css" rel="stylesheet">
<style type="text/css">
body {
	padding-bottom: 40px;
}

.sidebar-nav {
	padding: 9px 0;
}
</style>
	<script src="http://lib.sinaapp.com/js/jquery/2.2.4/jquery-2.2.4.min.js"></script>
	<script src="../js/common/public.js"></script>
	<script src="../js/base64.js"></script>
	<script src="../js/bootstrap-modal.js"></script>
	<script type="text/javascript">
        $(document).ready(function () {
            var urlMsg = parseUrl(window.location.search);
            $("#token").val(urlMsg.token);
            if (urlMsg.token != null) {
                var token = decode(urlMsg.token);
                token=token.substring(0,token.length-1);

            }
            var admin = $.ajax({
                type: "GET",
                url: "http://localhost:1068/admin/findAdminByUserName?token=" + token+"&userName="+urlMsg.userName,
                async: false
            }).responseText;
            var result = eval('(' + admin + ')');
            if (result.code != 200) {
                alert(result.msg)
            } else {
                if (result.data != null) {
                    $("#userName").val(result.data.userName);
                    $("#password").val(result.data.password);
                    $("#status").val(result.data.status);
                    $("#id").val(result.data.id);
                }
            }



        });

        function updateAdmin() {
            var urlMsg = parseUrl(window.location.search);
            $("#token").val(urlMsg.token);
            if (urlMsg.token != null) {
                var token = decode(urlMsg.token);
                token=token.substring(0,token.length-1);
            }
            var userName = $("#userName").val();
            var password =  $("#password").val();
            var status = $("#status").val();
            var id = $("#id").val();
            var html = $.ajax({
                type: "PUT",
                url: "http://localhost:1068/admin/updateAdmin",
                data:{token:token,userName:userName,password:password,status:status,id:id},
                async: false
            }).responseText;
            var result = eval('(' + html + ')');
            if (result.code != 200) {
                alert(result.msg)
            } else {
                alert("更新管理员信息成功！")
                window.location.href=document.referrer;
            }
        }
	</script>
</head>

<body>
	<div class="container-fluid"
		style="padding-left:0px;padding-right:2px;">
		<div class="row-fluid">
			<div id="content" class="span10" style="width:100%;">
				<div class="row-fluid sortable">
					<div class="box span12">
						<div class="box-header well">
							<h2>
								<i class="icon-edit"></i>修改管理员信息
							</h2>
						</div>
						<div class="box-content" style="text-align:center; padding-top:50px">
							<form action="admin/edit_admindeal.action" method="post">
							<input type="hidden" name="id" id="id" value="">
							<fieldset>
								<h1>修改管理员信息</h1>
								<br><br>
							  <div class="control-group">
								<div class="controls">
								  <span style="font-size:14px">用户名称：</span><input name="username" value="" class="input" id="userName" type="text" style="height:30px;">
								</div>
							  </div>
							  <br>
							  <div class="control-group">
								<div class="controls">
								  <span style="font-size:14px">用户密码：</span><input name="password" value="" class="input" id="password" type="text" style="height:30px;">
								</div>
							  </div>
							  <br>
							  
							  <div class="control-group">
								<div class="controls">
								  <span style="font-size:14px">用户状态：</span>
								  <select name="status" id="status"  style="width:210px;">
										  <option value="1">启用</option>
										  <option value="0">锁定</option>

									  </c:if>
								  </select>
								</div>
							  </div>
							  
							  <div class="form-actions">
								<button type="button" onclick="updateAdmin()" class="btn btn-primary" style="width:100px;">提交</button>
								&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								<button class="btn"  onclick="javascript:history.go(-1);" type="reset" style="width:100px;">取消</button>
							  </div>
							</fieldset>
							</form>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
</html>